PROGRAM MAPS
USE POLYMORPHIC_COMPLEXTAYLOR
TYPE(DAMAP) ROT,SEXT,TOTAL_DA_MAP
REAL(DP) ANGLE,KICK_STRENGTH
type(tree) map_track,map_track_da
real(dp) ray(lnv),ray_da(lnv),ray2(lnv),ray2_da(lnv)
integer mf
mf=20
open(unit=mf,file='results.txt')
CALL INIT(NO1=2,ND1=1,NP1=0,NDPT1 =0)     !   <------------------ init for maps in ND1 degrees of freedom

CALL ALLOC(ROT,SEXT,TOTAL_DA_MAP)
call alloc(map_track,map_track_da); 

ANGLE=31.0_DP * PI/180.0_DP






ROT%V(1)= (COS(ANGLE).MONO.'10') + (SIN(ANGLE).MONO.'01') -1.d-1
ROT%V(2)= (COS(ANGLE).MONO.'01') - (SIN(ANGLE).MONO.'10') -2.d-1

KICK_STRENGTH=3.0_DP

SEXT%V(1)= (1.0_DP.MONO.'10') +.01d0
SEXT%V(2)= (1.0_DP.MONO.'01') + (KICK_STRENGTH.MONO.'20') +.02d0

TOTAL_DA_MAP=SEXT*ROT   ! <---- * PERFORMS A DA-CONCATENATION OF TWO DAMAPS



! This illustrates, using two trees, that tracking with a tree or a map is always a TPSA computation
! where the zeroth order part is included
map_track=TOTAL_DA_MAP
rot=TOTAL_DA_MAP-(TOTAL_DA_MAP.sub.0)
map_track_da=rot   ! substracts the zeroth component

ray=0.d0;ray(1)=0.02d0;
ray_da=0.d0;ray_da(1)=0.02d0;
ray2=0.d0;ray2(1)=0.02d0;
ray2_da=0.d0;ray2_da(1)=0.02d0;

write(mf,'(1x,8(1x,F7.5))') ray(1:2),ray_da(1:2),ray2(1:2),ray2_da(1:2)

do i=1,100
ray=map_track*ray
ray_da=map_track_da*ray_da
ray2=TOTAL_DA_MAP*ray2
ray2_da=rot*ray2_da
write(mf,'(1x,8(1x,F7.5))') ray(1:2),ray_da(1:2),ray2(1:2),ray2_da(1:2)
enddo




CALL KILL(ROT,SEXT,TOTAL_DA_MAP)
call KILL(map_track,map_track_da);
close(20)
END PROGRAM MAPS

